#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    // 创建QMessageBox
    QMessageBox* messageBox = new QMessageBox(this);
    messageBox->setWindowTitle("对话框标题");
    messageBox->setText("对话框文本");
    messageBox->setIcon(QMessageBox::Warning);

    messageBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Save | QMessageBox::Cancel);

    int result = messageBox->exec();
    if(result == QMessageBox::Ok){
        qDebug() << "ok";
    }else if(result == QMessageBox::Save){
        qDebug() << "save";
    }else if(result == QMessageBox::Cancel){
        qDebug() << "cancel";
    }

    messageBox->setAttribute(Qt::WA_DeleteOnClose);
}
